// pages/index/entrance/entrance.ts
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    goodsTypeList: {
      type: Array,
      observer: function () {
        const size = this.properties.goodsTypeSize
        const totalPage = Math.ceil(this.properties.goodsTypeList.length / size)
        const data = this.properties.goodsTypeList.filter((v, k) => k < size && k >= 0)
        this.setData({
          goodsTypeAll: data,
          goodsTypeTotalPage: totalPage
        })
      }
    },
    goodsTypeSize: {
      type: Number,
      value: 3
    }
  },
  /**
   * 组件的初始数据
   */
  data: {
    goodsTypeTotalPage: 1,
    goodsTypeAll: [] as any
  },
  /**
   * 组件的方法列表
   */
  methods: {
    swiper_change(current: any, source: any) {
      this.getGoodsPage(current.detail.current)
    },
    getGoodsPage(pageNum = 0) {
      //从0 开始
      const size = this.properties.goodsTypeSize
      this.setData({
        goodsTypeAll: this.properties.goodsTypeList.filter((v, k) => k <= size*(pageNum  +1)-1 && k >= size*pageNum  )
      })
    }
  }
})